import http from '@/utils/http'
import { ShowType } from '@/enums/constEnums'
import {
  AverageVisitTimeInterfaceRes,
  BounceRateInterfaceRes,
  DirectRateInterfaceRes,
  MaxConcurrentUsersInterfaceRes,
  PagesPerVisitInterfaceRes,
  UserLifeTimeInterfaceRes,
} from '@/api/productStickiness/types'
/**
 * @description 获取产品黏性-直访率数据
 * @param searchParams
 */
export function getDirectVisitRate(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<DirectRateInterfaceRes[]>(
    `/admin/productStickiness/directVisitRate/info`,
    searchParams,
  )
}
/**
 * @description 获取产品黏性-跳出率数据
 * @param searchParams
 */
export function getBounceRate(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<BounceRateInterfaceRes[]>(
    `/admin/productStickiness/bounceRate/info`,
    searchParams,
  )
}
/**
 * @description 获取产品黏性-人均页面浏览量PV
 * @param searchParams
 */
export function getPagesPerVisit(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<PagesPerVisitInterfaceRes[]>(
    `/admin/productStickiness/pagesPerVisit/info`,
    searchParams,
  )
}
/**
 * @description 获取产品黏性-平均访问时长
 * @param searchParams
 */
export function getAverageVisitTime(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<AverageVisitTimeInterfaceRes[]>(
    `/admin/productStickiness/averageVisitTime/info`,
    searchParams,
  )
}
/**
 * @description 获取产品黏性-用户生命周期
 * @param searchParams
 */
export function getUserLifeTime(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<UserLifeTimeInterfaceRes[]>(
    `/admin/productStickiness/userLifeTime/info`,
    searchParams,
  )
}
/**
 * @description 获取产品黏性-最高同时在线人数
 * @param searchParams
 */
export function getMaxConcurrentUsers(searchParams: {
  type: ShowType // 汇总0 PC端 1 移动端 2
  dateRange: string[] // 日期范围
}) {
  return http.post<MaxConcurrentUsersInterfaceRes[]>(
    `/admin/productStickiness/maxConcurrentUsers/info`,
    searchParams,
  )
}
